<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>我的任务</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
        <div>
            <div id="pageInTab" class="pageInTab">
                <div tabid="tabA" title="我的提成" lselected="true">
                	<div class="searchArea">
					    <form id="searchBar">
					        <div class="fieldset1 clearFix">
					            <div class="fieldBox">
					                <div class="label" style="width: 60px;">应提成人</div>
					                <div class="field">
					                    <input name="usrNm" id="usrNm" type="text" class="ui-textbox" value="">
					                </div>
					            </div>
					            <div class="fieldBox">
					                <div class="label" style="width: 80px;">应提成人工号</div>
					                <div class="field">
					                    <input name="usrCd" id="usrCd" type="text" class="ui-textbox" value="">
					                </div>
					            </div>
							  <div class="fieldBox">
							              <div class="label">提成所属月份</div>
							              <div class="field">
							                  <input ligerui="width: 82" name="achMthSart" id="achMthSart" type="text"
							                         class="ui-datepicker" value="" validate="{required:true}"  >
							             -
							             <input ligerui="width: 82" name="achMthEnd" id="achMthEnd" type="text"
							                    class="ui-datepicker" value="" validate="{required:true}">
							         </div>
							     </div>
							      <div class="fieldBox">
							              <div class="label">提成发放月份</div>
							              <div class="field">
							                  <input ligerui="width: 82" name="achPayMthStart" id="achPayMthStart" type="text"
							                         class="ui-datepicker" value="" validate="{required:true}"  >
							             -
							             <input ligerui="width: 82" name="achPayMthEnd" id="achPayMthEnd" type="text"
							                    class="ui-datepicker" value="" validate="{required:true}"  >
							         </div>
							     </div>
							     
								<sys:funcAuth resCd="jxsc003">
					                   <div class="fieldBox">
					                       <div class="field">
					                           <jsp:include page="../../system/sysUlFilesRec/sysSysUlFilesRecUpload.jsp" flush="true" >
					                               <jsp:param name="fileNum" value="1"/>
					                               <jsp:param name="filePath" value="capital/capFund"/>
					                           </jsp:include>
					                       </div>
					                       <div class="field">
					                           <span id="addBatchBtn" class="sq-button sq-button-round" onclick="addBatch();">批量导入</span>
					                       </div>
					                   </div>
					               </sys:funcAuth>
								           
					            <div class="clearFix"></div>
					            <div class="btnsBox">
					               <span id="searchBtn" class="sq-button sq-button-round">查询</span>
					               <span onclick="clearBtn();" class="sq-button sq-button-round">清空</span>
					               
					               <sys:funcAuth resCd="jxmbxz002">
					               <span id="downTempBtn" class="sq-button sq-button-round" onclick="downTemp();">下载模板</span>
					               </sys:funcAuth>
					               
					               <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
					               <input name="isSignNm" id="isSignId" type="text" style="display: none;" value="0"/>
					            </div>
					        </div>
					    </form>
					</div>
                    <div id="ligergridDB" class="sq-grid"></div>
                </div>
                <sys:funcAuth resCd="jxlsfj001">
                <div tabid="tabB" title="历史附件">
                     <iframe frameborder="0" name="tabB" id="tabB" src=""></iframe>
                </div>
                </sys:funcAuth>
            </div>
        </div>
    </div>

<script type="text/javascript">
	var gridDB = null;
	var pageInApp={}; // to 下一级子窗口 接口
    var pageInTab=null;
    var loadedTabs=[]
	$(function () {
		$("#exeFlowId").hide();
		$("#privateTaskId").hide();
		initTab();
		initGridDB();//初始化待办列表
	    $("#searchBar").ligerForm();
	    $("#searchBtn").click(function(event) {
	    	reloadGrid();
	    });
	});
    
    function downTemp(){
        window.location.href="<%=path%>/resource/template/capital/month_KPI.xls";
    }
    
    //批量导入
    function addBatch(){
        //获取上传文件地址
        var files=getUploadResultParams();
        //var files=[{filePath:'C:/UPLOADTEST/capital/capFund/1472614427515.xls'}];
        if(files&&files.length>0){
            var filePath=files[0].filePath;
            var fileExtension = filePath.substring(filePath.lastIndexOf('.') + 1);
            if(fileExtension!='xls'&&fileExtension!='XLS'){
                $.ligerDialog.SQalert({content: "请上传.xls后缀的资金文件", SQ_type: "warn"});
                return;
            }
            $.ligerDialog.open({
                cls: 'noBorder_Dialog',
                width: 1000,
                height: 500,
                title: '绩效导入数据',
                url: '<%=path%>/bizflow/rskUsrAchLog/toAchievementsImportPage.do?filePath=' +files[0].filePath+'&fileNm='+files[0].fileNm,                
            });
        }else{
            $.ligerDialog.SQalert({content: "请先上传资金文件", SQ_type: "warn"});
        }
    }
    
    //重新加载GRID
    function reloadGrid(){
    	var form = new liger.get("searchBar");
        var data = form.getData();
        for (name in data){
	        gridDB.setParm(name,data[name]);
	    };
	    gridDB.reload();
    }
    
    //初始化列表
    function initGridDB(){
    	$("#ligergridDB").ligerGrid({
	    	url: '<%=path%>/bizflow/rskUsrAchLog/initList.do',
	    	method : 'get',
	        columns: [
	            { display: '提成所属月份', name: 'achMth',  width: 90,align: 'center', enabledSort:false,render: renderDate2},
	            { display: '提成发放月份', name: 'achPayMth',  minWidth: 90, align: 'center',enabledSort:false,render: renderDate2},
	            { display: '省份', name: 'proNm',  width: 120, enabledSort:false},
	            { display: '工号', name: 'usrCd',  width: 100, enabledSort:false},
	            { display: '应提成人', name: 'usrNm', minWidth: 120 , enabledSort:false},
	            { display: '应提成人所属公司', name: 'usrOrgNm', width: 100,align:'left' , enabledSort:false},
	            { display: '应提成人职能', name: 'usrFunNm', minWidth: 100 , enabledSort:false},
	            { display: '提成所属人员岗位', name: 'usrPostNm', minWidth: 120 , enabledSort:false},
	            { display: '支付表号', name: 'paySchNo', minWidth: 100 , enabledSort:false},
	            { display: '客户名称', name: 'cstNm', minWidth: 100 , enabledSort:false},
	            { display: '提成类别(放款提成&回款提成&考察费)', name: 'achTypNm', minWidth: 140 , enabledSort:false},
	            { display: '业务类型(车队业务、城配业务、传统业务旧政策、传统业务新政策、再融资)', name: 'buTypNm', minWidth: 140 , enabledSort:false},
	            { display: '标准发放金额 (未考虑任何考核)', name: 'achAmt', minWidth: 140 , enabledSort:false,
	            	 render: function (rowdata, index, value) {
	                        return '&yen;' + FormatMoney(rowdata.achAmt / 100);
	                    }	
	            }, 
	            { display: '实际发放金额', name: 'realAchAmt', minWidth: 100 , enabledSort:false,
	            	 render: function (rowdata, index, value) {
	                        return '&yen;' + FormatMoney(rowdata.realAchAmt / 100);
	                    }	
	            },
	            { display: '发放系数', name: 'outNmb', minWidth: 90 , enabledSort:false},
	        ],
	        pageSize:100,
	        pageSizeOptions: [10, 20, 30, 40, 50, 100],
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        height:'100%',
	        heightDiff:-30,
	        checkbox:true,
	        rownumbers:true
	    });
	    gridDB = liger.get("ligergridDB");
	    gridDB.setHeight(100);
	    gridDB.options.isSingleCheck=true;
    }
    
 
    //格式化时间
    function renderDate2(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
        }
        return dateStr;
    }


	function clearBtn(){
		$("#resetBtn").click();  //重置 input-text
		var form = liger.get("searchBar");
        $("#orgCd").val("");
        form.setData({  //重置select等特殊表单
            //"orgCd": " ",
            "businessType":" ",
            "bizResCd":" "
        });
       //searchOrgTree.clear();
	}
	
	function iframeResize () {
	    if (parent.mainApp) {
	        parent.mainApp.parentTab.onResize();
	    };
	}
	
	
	//初始化Tab页
    function initTab(){

        pageInTab = $("#pageInTab").ligerTab({
            height: 'auto',
            contextmenu: false,
            minIframeHeight: GET_minIframeHeight(),
            onAfterSelectTabItem: function(tabid) {
            	currTab = tabid;//赋值是哪个Tab页面
                if (loadedTabs.indexOf(tabid)<0) {
                    loadedTabs.push(tabid);
                    switch (tabid){
                        case "tabB":
                            pageInTab.setTabItemSrc(tabid, "<%=path%>/bizflow/rskUsrAchLog/toMyAchievementsPage.do");
                            break;
                    }
                };
                SetIframe_height();
            }
        });

        $.extend(true, pageInApp, {
            pageInTab: pageInTab
        });
    }
</script>

</body>
</html>